/*
 * @brief:
 * @Author: TzzzT
 * @Date: 2022-06-07 18:39:07
 * @LastEditTime: 2023-05-04 23:39:56
 * @LastEditors: TzzzT
 */
#pragma once

typedef enum dev_class_e
{
    NONE_DEV,
    GUN_POINT,
    GUN_SCREEN,
    ARMOR,
} dev_class_t;

/*
上报消息的数据块种类
数据块：数据块长度 + 数据块类型 + 数据
*/
typedef enum upload_data_type_e
{
    // common
    PACKAGE_LEN_UPL,
    MESSAGE_TYPE_BATTERY_UPL,
    // be hit
    ROOM_UPL,
    TEAM_UPL,
    DAMAGE_UPL,
    PLAYER_ID_UPL,
    // fire
    REMAIN_BULLET_NUM_UPL,
    // command
    COMMAND_UPL,
    DATA_UPLOAD_CLASS_NUM
} upload_data_type_t;

// PACKAGE_LEN数据块的长度
#define PACKAGE_LEN_UPL_LEN 3

// MESSAGE_TYPE_BATTERY_UPL数据块的长度 ：len + 数据块类型 + data_type + batt
#define MESSAGE_TYPE_BATTERY_UPL_LEN 4

// COMMAND_UPL数据块：3  len + COMMAND_UPL + command_type_t
#define COMMAND_UPL_LEN 3

// 3. 被击中消息   ARMOR_BE_HITTED_TYPE
#define ROOM_UPL_LEN 3
#define TEAM_UPL_LEN 3
#define DAMAGE_UPL_LEN 4
#define PLAYER_ID_UPL_LEN 5

// 4. 开火消息   GUN_POINT_FIRE_TYPE
#define REMAIN_BULLET_NUM_UPL_LEN 4

#define GUN_POI_UPL_PACK_MAX_LEN (PACKAGE_LEN_UPL_LEN + MESSAGE_TYPE_BATTERY_UPL_LEN + REMAIN_BULLET_NUM_UPL_LEN)

#define GUN_SCR_UPL_PACK_MAX_LEN (PACKAGE_LEN_UPL_LEN + MESSAGE_TYPE_BATTERY_UPL_LEN + REMAIN_BULLET_NUM_UPL_LEN)

#define ARMOR_UPL_PACK_MAX_LEN (PACKAGE_LEN_UPL_LEN + MESSAGE_TYPE_BATTERY_UPL_LEN + ROOM_UPL_LEN + TEAM_UPL_LEN + DAMAGE_UPL_LEN + PLAYER_ID_UPL_LEN)

// 消息类型和电量 MESSAGE_TYPE_BATTERY_UPL
typedef enum message_type_e
{
    // from gun
    GUN_POINT_VER_TYPE = 0xA0, // 枪口验证
    GUN_POINT_FIRE_TYPE,
    GUN_POINT_COMMAND_TYPE,
    GUN_POINT_BATTERY_TYPE,
    GUN_POINT_CLOSE_CONNECT_TYPE,
    GUN_SCREEN_VER_TYPE, // 枪屏幕验证
    GUN_SCREEN_COMMAND_TYPE,
    GUN_SCREEN_BATTERY_TYPE,
    GUN_SCREEN_CLOSE_CONNECT_TYPE,
    // from armor
    ARMOR_VER_TYPE = 0xB0,
    ARMOR_COMMAND_TYPE,
    ARMOR_BE_HITTED_TYPE,
    ARMOR_BATTERY_TYPE,
    ARMOR_CLOSE_CONNECT_TYPE,
    // from core
    CORE_ARMOR_COMMAND_TYPE = 0xD1,
    CORE_ARMOR_BE_HITTED_TYPE,
    CORE_FIRE_TYPE,
} message_type_t;

// 消息种类列表
// 1. 每种设备校验身份和上传电量的消息  GUN_POINT_VER_TYPE/GUN_SCREEN_VER_TYPE/ARMOR_VER_TYPE

// 2. 使用道具或者接收了红外指令消息   GUN_SCR_COMMAND_TYPE/ARMOR_COMMAND_TYPE
// nfc或者红外遥控的命令种类
typedef enum command_type_e
{
    START_GAME_COMM = 69,
    END_GAME_COMM = 71,
    INCREASE_DAMAGE_COMM = 21,
    DECREASE_DAMAGE_COMM = 7,
    INCREASE_HP_COMM = 25,
    DECREASE_HP_COMM = 22,
    INCREASE_BULLET_COMM = 9,
    KILL_COMM = 13,
    REBORN_COMM = 64,
    SET_TEAM_A_COMM = 12,
    SET_TEAM_B_COMM = 24,
    RESET_ALL_COMM = 68,
    FIX_BULLET_MODE_START = 94,
    FIX_BULLET_MODE_STOP = 8,
    CONTINUE_BULLET_MODE = 28,
} command_type_t;

typedef enum station_command_e
{
    RESOURCE_STA_COMM = 7,
    HP_CURE_STA_COMM = 25,
    HP_DROP_STA_COMM = 22,
    SAFETY_STA_COMM = 9, // apex 隔热板
    INVINCIBLE_STA_COMM = 13,
    REBORN_P_STA_COMM = 64,
    TEAM_A_STA_COMM = 12,
    TEAM_B_STA_COMM = 24,
    DEFAULT_STA_COMM = 68
} station_command_type_t;

// NOTIFY
typedef enum notify_data_type_e
{
    PACKAGE_LEN_NOTIFY = 0,
    PLAYER_ID_NOTIFY,  // 5 显示屏用
    LIVING_NOTIFY,     // 3
    GAME_START_NOTIFY, // 3

    TEAM_NOTIFY,   // 3
    ROOM_NOTIFY,   // 3
    HP_NOTIFY,     // 4
    DAMAGE_NOTIFY, // 4

    BULLET_NUM_NOTIFY,   // 4
    CONN_CLI_NUM_NOTIFY, // 3
    LOW_WARNING_NOTIFY,  // 3 显示屏用
    AUDIO_SN_NOTIFY,     // 3  需要播放的音频序列号

    DEATH_NOTIFY,         // 3
    KILL_NOTIFY,          // 3
    TEAM_SCORE_NOTIFY,    // 4
    CLOSE_CONNECT_NOTIFY, // 2

    POWER_OFF_NOTIFY, // 2
    BE_HITTED_NOTIFY,
    SCRHINT_NOTIFY, //
    SCRBATT_NOTIFY,

    NET_STATE_NOTIFY,

    DATA_NOTIFY_CLASS_NUM
} notify_data_type_t;

typedef uint32_t notify_mask_t;

// 下列的mask都除去第一位PACKAGE_LEN_NOTIFY，避免重复计算。
#define ARMOR_INIT_MASK 0x007e
#define POINT_INIT_MASK 0x01fe
#define SCREEN_INIT_MASK 0x1877fe

#define RESET_PLAYER_MASK 0x71f4

#define POINT_MASK_ARANGE 0x381fe
#define SCREEN_MASK_ARANGE 0xfffffe
#define ARMOR_MASK_ARANGE 0x1807e

// 通知从机
#define PACKAGE_LEN_NOTI_LEN 3
#define PLAYER_ID_NOTI_LEN 5
#define LIVING_NOTI_LEN 3
#define GAME_START_NOTI_LEN 3
#define TEAM_NOTI_LEN 3

#define ROOM_NOTI_LEN 3
#define HP_NOTI_LEN 4
#define DAMAGE_NOTI_LEN 4
#define BULLET_NUM_NOTI_LEN 4
#define CONN_CLI_NUM_NOTI_LEN 3

#define LOW_WARNING_NOTI_LEN 3
#define AUDIO_SN_NOTI_LEN 3
#define DEATH_NOTI_LEN 3
#define KILL_NOTI_LEN 3
#define TEAM_SCORE_NOTI_LEN 4

#define CLOSE_CONNECT_NOTI_LEN 2
#define POWER_OFF_NOTI_LEN 2
#define BE_HITTED_NOTI_LEN 2

#define SCRHINT_NOTI_LEN 9 // len + scrshow flag + 7 char
#define SCRBATT_NOTI_LEN 6 // len + scrbatt flag + 4

#define NETSTAT_NOTI_LEN 3 // len + netstate flag + 1

/*
控制板与网络服务器通信
2.通过4g模块

服务器下发数据给控制板(download data), 见SERVER_DATA_TYPE_UPL数据块。

控制板上传数据给服务器：send_to_server_data_type_t

*/
typedef enum error_net_source_e
{
    REMOTE_UNKNOWN,
    NFC_UNKNOWN,
    STATION_UNKNOWN,
} error_net_source_t;

// 上传网络服务器的数据类型
typedef enum send_to_server_data_type_e
{
    RESPONSE_NET_UP = 10,
    HEARTBEAT_NET_UP,
    USE_BULLET_NET_UP,
    BE_HITTED_NET_UP,
    PROPPERTY_CHANGE_NET_UP,
    START_GAME_NET_UP,
    ERROR_NET_UP,
} send_to_server_data_type_t;

// 上传网络服务器的数据类型
typedef enum recei_from_server_data_type_e
{
    START_NET_DOWN = 20,
    MODIFY_PROPS_NET_DOWN,
    CONTROL_NET_DOWN,
    GAME_START_NET_DOWN,
    HEARTBEAT_FEEDBACK_NET_DOWN = 50,
} recei_from_server_data_type_t;

//////////////////STATION////////////////////

typedef enum staion_type_e
{
    DEFAULT_STATION,
    RESOURCE_STATION,
    SAFETY_STATION,
    TEAM_A_STATION,
    TEAM_B_STATION,
    REBORN_STATION,
    HP_DROP_STATION,
    HP_CURE_STATION,
    INVINCIBLE_STATION,
    STATION_CLASS_NUM,
    NONE_STATION,
} station_type_t;
